package com.perfma.xtest.tool.leetcode;

/**
 * 回文数
 * <p>
 * 给你一个整数 x ，如果 x 是一个回文整数，返回 true ；否则，返回 false 。
 * <p>
 * 回文数是指正序（从左向右）和倒序（从右向左）读都是一样的整数。例如，121 是回文，而 123 不是。
 * <p>
 * <p>
 * <p>
 * 来源：力扣（LeetCode）
 * 链接：https://leetcode-cn.com/problems/palindrome-number
 * 著作权归领扣网络所有。商业转载请联系官方授权，非商业转载请注明出处。
 *
 * @author: junhui.si
 * @date: 2022-01-20 15:32
 **/
public class Code9 {
    public static void main(String[] args) {
        String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<jmeterTestPlan version=\"1.2\" properties=\"5.0\" jmeter=\"5.1.1 r1855137\">\n" +
                "  <hashTree>\n" +
                "    <TestPlan guiclass=\"TestPlanGui\" testclass=\"TestPlan\" testname=\"isp-派单\" enabled=\"true\">\n" +
                "      <stringProp name=\"TestPlan.comments\"></stringProp>\n" +
                "      <boolProp name=\"TestPlan.functional_mode\">false</boolProp>\n" +
                "      <boolProp name=\"TestPlan.tearDown_on_shutdown\">true</boolProp>\n" +
                "      <boolProp name=\"TestPlan.serialize_threadgroups\">false</boolProp>\n" +
                "      <elementProp name=\"TestPlan.user_defined_variables\" elementType=\"Arguments\" guiclass=\"ArgumentsPanel\" testclass=\"Arguments\" testname=\"用户定义的变量\" enabled=\"true\">\n" +
                "        <collectionProp name=\"Arguments.arguments\"/>\n" +
                "      </elementProp>\n" +
                "      <stringProp name=\"TestPlan.user_define_classpath\"></stringProp>\n" +
                "    </TestPlan>\n" +
                "    <hashTree>\n" +
                "      <ThreadGroup guiclass=\"ThreadGroupGui\" testclass=\"ThreadGroup\" testname=\"isp-派单\" enabled=\"true\">\n" +
                "        <stringProp name=\"ThreadGroup.on_sample_error\">continue</stringProp>\n" +
                "        <elementProp name=\"ThreadGroup.main_controller\" elementType=\"LoopController\" guiclass=\"LoopControlPanel\" testclass=\"LoopController\" testname=\"循环控制器\" enabled=\"true\">\n" +
                "          <boolProp name=\"LoopController.continue_forever\">false</boolProp>\n" +
                "          <intProp name=\"LoopController.loops\">-1</intProp>\n" +
                "        </elementProp>\n" +
                "        <stringProp name=\"ThreadGroup.num_threads\">100</stringProp>\n" +
                "        <stringProp name=\"ThreadGroup.ramp_time\">1</stringProp>\n" +
                "        <boolProp name=\"ThreadGroup.scheduler\">false</boolProp>\n" +
                "        <stringProp name=\"ThreadGroup.duration\"></stringProp>\n" +
                "        <stringProp name=\"ThreadGroup.delay\"></stringProp>\n" +
                "      </ThreadGroup>\n" +
                "      <hashTree>\n" +
                "        <ResultCollector guiclass=\"ViewResultsFullVisualizer\" testclass=\"ResultCollector\" testname=\"察看结果树\" enabled=\"true\">\n" +
                "          <boolProp name=\"ResultCollector.error_logging\">false</boolProp>\n" +
                "          <objProp>\n" +
                "            <name>saveConfig</name>\n" +
                "            <value class=\"SampleSaveConfiguration\">\n" +
                "              <time>true</time>\n" +
                "              <latency>true</latency>\n" +
                "              <timestamp>true</timestamp>\n" +
                "              <success>true</success>\n" +
                "              <label>true</label>\n" +
                "              <code>true</code>\n" +
                "              <message>true</message>\n" +
                "              <threadName>true</threadName>\n" +
                "              <dataType>true</dataType>\n" +
                "              <encoding>false</encoding>\n" +
                "              <assertions>true</assertions>\n" +
                "              <subresults>true</subresults>\n" +
                "              <responseData>true</responseData>\n" +
                "              <samplerData>true</samplerData>\n" +
                "              <xml>true</xml>\n" +
                "              <fieldNames>true</fieldNames>\n" +
                "              <responseHeaders>true</responseHeaders>\n" +
                "              <requestHeaders>true</requestHeaders>\n" +
                "              <responseDataOnError>false</responseDataOnError>\n" +
                "              <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>\n" +
                "              <assertionsResultsToSave>0</assertionsResultsToSave>\n" +
                "              <bytes>true</bytes>\n" +
                "              <sentBytes>true</sentBytes>\n" +
                "              <url>true</url>\n" +
                "              <threadCounts>true</threadCounts>\n" +
                "              <idleTime>true</idleTime>\n" +
                "              <connectTime>true</connectTime>\n" +
                "            </value>\n" +
                "          </objProp>\n" +
                "          <stringProp name=\"filename\"></stringProp>\n" +
                "        </ResultCollector>\n" +
                "        <hashTree/>\n" +
                "        <ResultCollector guiclass=\"StatVisualizer\" testclass=\"ResultCollector\" testname=\"聚合报告\" enabled=\"true\">\n" +
                "          <boolProp name=\"ResultCollector.error_logging\">false</boolProp>\n" +
                "          <objProp>\n" +
                "            <name>saveConfig</name>\n" +
                "            <value class=\"SampleSaveConfiguration\">\n" +
                "              <time>true</time>\n" +
                "              <latency>true</latency>\n" +
                "              <timestamp>true</timestamp>\n" +
                "              <success>true</success>\n" +
                "              <label>true</label>\n" +
                "              <code>true</code>\n" +
                "              <message>true</message>\n" +
                "              <threadName>true</threadName>\n" +
                "              <dataType>true</dataType>\n" +
                "              <encoding>false</encoding>\n" +
                "              <assertions>true</assertions>\n" +
                "              <subresults>true</subresults>\n" +
                "              <responseData>true</responseData>\n" +
                "              <samplerData>true</samplerData>\n" +
                "              <xml>true</xml>\n" +
                "              <fieldNames>true</fieldNames>\n" +
                "              <responseHeaders>true</responseHeaders>\n" +
                "              <requestHeaders>true</requestHeaders>\n" +
                "              <responseDataOnError>false</responseDataOnError>\n" +
                "              <saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>\n" +
                "              <assertionsResultsToSave>0</assertionsResultsToSave>\n" +
                "              <bytes>true</bytes>\n" +
                "              <sentBytes>true</sentBytes>\n" +
                "              <url>true</url>\n" +
                "              <threadCounts>true</threadCounts>\n" +
                "              <idleTime>true</idleTime>\n" +
                "              <connectTime>true</connectTime>\n" +
                "            </value>\n" +
                "          </objProp>\n" +
                "          <stringProp name=\"filename\"></stringProp>\n" +
                "        </ResultCollector>\n" +
                "        <hashTree/>\n" +
                "        <ThroughputController guiclass=\"ThroughputControllerGui\" testclass=\"ThroughputController\" testname=\"isp-派单-正常\" enabled=\"true\">\n" +
                "          <intProp name=\"ThroughputController.style\">1</intProp>\n" +
                "          <boolProp name=\"ThroughputController.perThread\">false</boolProp>\n" +
                "          <intProp name=\"ThroughputController.maxThroughput\">1</intProp>\n" +
                "          <FloatProperty>\n" +
                "            <name>ThroughputController.percentThroughput</name>\n" +
                "            <value>100.0</value>\n" +
                "            <savedValue>0.0</savedValue>\n" +
                "          </FloatProperty>\n" +
                "        </ThroughputController>\n" +
                "        <hashTree>\n" +
                "          <io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample guiclass=\"io.github.ningyu.jmeter.plugin.dubbo.gui.DubboSampleGui\" testclass=\"io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample\" testname=\"正常派单\" enabled=\"true\">\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_PROTOCOL\">zookeeper</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_RPC_PROTOCOL\">dubbo://</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_ADDRESS\">10.10.226.134:2181,10.10.226.104:2181,10.10.226.106:2181</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_TIMEOUT\">60000</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_VERSION\">1.0.0</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_RETRIES\">0</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_GROUP\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONNECTIONS\">100</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_LOADBALANCE\">random</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_ASYNC\">sync</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CLUSTER\">failfast</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_INTERFACE\">cn.wonhigh.retail.ios.api.service.IosRefuseOrderApi</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD\">dispatch</stringProp>\n" +
                "            <intProp name=\"FIELD_DUBBO_METHOD_ARGS_SIZE\">3</intProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_TYPE1\">java.lang.String</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_VALUE1\">${order_sub_no}</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_TYPE2\">java.lang.String</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_VALUE2\">${sharding_flag}</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_TYPE3\">java.lang.String</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_VALUE3\">${validate_batch}</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_PROTOCOL\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_GROUP\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_NAMESPACE\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_USER_NAME\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_PASSWORD\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_ADDRESS\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_TIMEOUT\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_GROUP\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_USER_NAME\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_PASSWORD\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_TIMEOUT\"></stringProp>\n" +
                "            <intProp name=\"FIELD_DUBBO_ATTACHMENT_ARGS_SIZE\">0</intProp>\n" +
                "          </io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample>\n" +
                "          <hashTree>\n" +
                "            <CSVDataSet guiclass=\"TestBeanGUI\" testclass=\"CSVDataSet\" testname=\"CSV 数据文件设置\" enabled=\"true\">\n" +
                "              <stringProp name=\"delimiter\">,</stringProp>\n" +
                "              <stringProp name=\"fileEncoding\">UTF-8</stringProp>\n" +
                "              <stringProp name=\"filename\">./正常派单.txt</stringProp>\n" +
                "              <boolProp name=\"ignoreFirstLine\">false</boolProp>\n" +
                "              <boolProp name=\"quotedData\">false</boolProp>\n" +
                "              <boolProp name=\"recycle\">false</boolProp>\n" +
                "              <stringProp name=\"shareMode\">shareMode.all</stringProp>\n" +
                "              <boolProp name=\"stopThread\">true</boolProp>\n" +
                "              <stringProp name=\"variableNames\">order_sub_no,sharding_flag,validate_batch</stringProp>\n" +
                "            </CSVDataSet>\n" +
                "            <hashTree/>\n" +
                "            <ResponseAssertion guiclass=\"AssertionGui\" testclass=\"ResponseAssertion\" testname=\"响应断言\" enabled=\"true\">\n" +
                "              <collectionProp name=\"Asserion.test_strings\"/>\n" +
                "              <stringProp name=\"Assertion.custom_message\"></stringProp>\n" +
                "              <stringProp name=\"Assertion.test_field\">Assertion.response_data</stringProp>\n" +
                "              <boolProp name=\"Assertion.assume_success\">false</boolProp>\n" +
                "              <intProp name=\"Assertion.test_type\">16</intProp>\n" +
                "            </ResponseAssertion>\n" +
                "            <hashTree/>\n" +
                "          </hashTree>\n" +
                "        </hashTree>\n" +
                "        <ThroughputController guiclass=\"ThroughputControllerGui\" testclass=\"ThroughputController\" testname=\"isp-派单-高频\" enabled=\"false\">\n" +
                "          <intProp name=\"ThroughputController.style\">1</intProp>\n" +
                "          <boolProp name=\"ThroughputController.perThread\">false</boolProp>\n" +
                "          <intProp name=\"ThroughputController.maxThroughput\">1</intProp>\n" +
                "          <FloatProperty>\n" +
                "            <name>ThroughputController.percentThroughput</name>\n" +
                "            <value>10.0</value>\n" +
                "            <savedValue>0.0</savedValue>\n" +
                "          </FloatProperty>\n" +
                "        </ThroughputController>\n" +
                "        <hashTree>\n" +
                "          <io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample guiclass=\"io.github.ningyu.jmeter.plugin.dubbo.gui.DubboSampleGui\" testclass=\"io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample\" testname=\"高频派单\" enabled=\"false\">\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_PROTOCOL\">zookeeper</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_RPC_PROTOCOL\">dubbo://</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_ADDRESS\">10.10.226.134:2181,10.10.226.104:2181,10.10.226.106:2181</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_TIMEOUT\">1000</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_VERSION\">1.0.0</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_RETRIES\">0</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_GROUP\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONNECTIONS\">100</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_LOADBALANCE\">random</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_ASYNC\">sync</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CLUSTER\">failfast</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_INTERFACE\">cn.wonhigh.retail.ios.api.service.IosRefuseOrderApi</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD\">dispatch</stringProp>\n" +
                "            <intProp name=\"FIELD_DUBBO_METHOD_ARGS_SIZE\">3</intProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_TYPE1\">java.lang.String</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_VALUE1\">${order_sub_no}</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_TYPE2\">java.lang.String</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_VALUE2\">${sharding_flag}</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_TYPE3\">java.lang.String</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_METHOD_ARGS_PARAM_VALUE3\">${validate_batch}</stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_PROTOCOL\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_GROUP\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_NAMESPACE\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_USER_NAME\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_PASSWORD\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_ADDRESS\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_CONFIG_CENTER_TIMEOUT\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_GROUP\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_USER_NAME\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_PASSWORD\"></stringProp>\n" +
                "            <stringProp name=\"FIELD_DUBBO_REGISTRY_TIMEOUT\"></stringProp>\n" +
                "            <intProp name=\"FIELD_DUBBO_ATTACHMENT_ARGS_SIZE\">0</intProp>\n" +
                "          </io.github.ningyu.jmeter.plugin.dubbo.sample.DubboSample>\n" +
                "          <hashTree>\n" +
                "            <CSVDataSet guiclass=\"TestBeanGUI\" testclass=\"CSVDataSet\" testname=\"CSV 数据文件设置\" enabled=\"false\">\n" +
                "              <stringProp name=\"delimiter\">,</stringProp>\n" +
                "              <stringProp name=\"fileEncoding\">UTF-8</stringProp>\n" +
                "              <stringProp name=\"filename\">./高频派单.txt</stringProp>\n" +
                "              <boolProp name=\"ignoreFirstLine\">false</boolProp>\n" +
                "              <boolProp name=\"quotedData\">false</boolProp>\n" +
                "              <boolProp name=\"recycle\">false</boolProp>\n" +
                "              <stringProp name=\"shareMode\">shareMode.all</stringProp>\n" +
                "              <boolProp name=\"stopThread\">true</boolProp>\n" +
                "              <stringProp name=\"variableNames\">order_sub_no,sharding_flag,validate_batch</stringProp>\n" +
                "            </CSVDataSet>\n" +
                "            <hashTree/>\n" +
                "            <ResponseAssertion guiclass=\"AssertionGui\" testclass=\"ResponseAssertion\" testname=\"响应断言\" enabled=\"false\">\n" +
                "              <collectionProp name=\"Asserion.test_strings\"/>\n" +
                "              <stringProp name=\"Assertion.custom_message\"></stringProp>\n" +
                "              <stringProp name=\"Assertion.test_field\">Assertion.response_data</stringProp>\n" +
                "              <boolProp name=\"Assertion.assume_success\">false</boolProp>\n" +
                "              <intProp name=\"Assertion.test_type\">16</intProp>\n" +
                "            </ResponseAssertion>\n" +
                "            <hashTree/>\n" +
                "          </hashTree>\n" +
                "        </hashTree>\n" +
                "      </hashTree>\n" +
                "    </hashTree>\n" +
                "  </hashTree>\n" +
                "</jmeterTestPlan>\n";
        System.out.println(s.length());
        System.out.println(s.getBytes().length);
        System.out.println(s.substring(0,1024));
    }

    public boolean isPalindrome(int x) {
        if (x < 0 || x % 10 == 0) {
            return false;
        }
        if (x < 10) {
            return true;
        }

        // 12321 1221
        int reverse = 0;
        while (x > reverse) {
            // 1 12 123 1232 12321 | 1 12
            reverse = reverse * 10 + x % 10;
            // 1232 123 12 1 | 122 12
            x /= 10;
        }

        return reverse == x || reverse % 10 == x;
    }
}
